Programming Amazon Web Services by James Murty
Author:James Murty [James Murty]
Language: eng
Format: epub
Tags: COMPUTERS / Online Services / General
ISBN: 9780596551797
Publisher: O'Reilly Media
Published: 2009-02-08T16:00:00+00:00
Note
As long as the threads are in the sleep or run state, all is well. If any of the threads is in the dead state, it means that a receiver has crashed or been halted.
With the simulator running and waiting to receive messages, we can move over to the message sending console and send some new messages to the sqssim queue. To help the simulation run quickly, we will change the visibility timeout of the queue to 10 seconds.
irbm> sqs.set_queue_attributes(queue_url, 10, 'VisibilityTimeout') irbm> sqs.get_queue_attributes(queue_url) => {"ApproximateNumberOfMessages"=>0, "VisibilityTimeout"=>10}
Now that the queue is ready, we can send some test messages from our message-sending console. We will start with only a few, perhaps 20 to begin with. The content of each message will include a processing/sleep time value of five seconds, followed by a comma, then a brief note describing which message number this is in the series.
irbm> ptime = 5 irbm> 20.times {|i| sqs.send_message(queue_url, "#{ptime}, Message #{i}")}
As soon as we run these commands and the messages are sent, we can move back to the Simulator console to see notification log statements showing that the messages are being received and processed. These statements will look something like the following:
irbs> B1.1: received @Wed Sep 05 12:44:19 +1000 2007: '5, Message 1 - Event count: 1 B1.0: received @Wed Sep 05 12:44:20 +1000 2007: '5, Message 0 - Event count: 1 B1.1: deleted @Wed Sep 05 12:44:26 +1000 2007: '5, Message 1 - Event count: 2 B1.0: deleted @Wed Sep 05 12:44:26 +1000 2007: '5, Message 0 - Event count: 2
The log shows that there are two Receiver instances operating, identified as “B1.0” and “B1.1,” and that both are receiving and processing messages at the same time. The timestamp values printed in the log should show that the time taken to receive a message, process it, and delete it is slightly longer than five seconds.
We can check on the simulator’s progress in two ways. One is to retrieve the approximate number of messages remaining in the queue using the method get_queue_attributes in the message sending console:
irbm> sqs.get_queue_attributes(queue_url) => {"ApproximateNumberOfMessages"=>7, "VisibilityTimeout"=>10}
Alternatively, we can check the size of the event history hash stored in the Simulator class from the Simulator console. The history hash size will only give an indication of how many messages have been received, not how many of those have also been processed and deleted; but it serves as a decent estimate in this case.
irbs> perfect_sim.event_history.size => 4
Once all the queue’s messages have been processed, stop the simulator’s Receiver instances and confirm that all its threads are dead.
irbs> perfect_sim.stop_receivers irbs> perfect_sim.threads => [#<Thread:0x12aa098 dead>, #<Thread:0x12a50d4 dead>]
It is now time to analyze the message flow that was recorded during the simulation. To do this we will use the print_history method to display a summary of the interesting messages. However, if we run this method with no parameters, there will be nothing to display because, in our perfect simulated world, nothing interesting happened to any of the messages. Every message was received, processed, and deleted without errors or redeliveries.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12525)
Hello! Python by Anthony Briggs(9870)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9760)
The Mikado Method by Ola Ellnestam Daniel Brolund(9751)
Dependency Injection in .NET by Mark Seemann(9296)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8261)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7744)
Grails in Action by Glen Smith Peter Ledbrook(7670)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7520)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6754)
Microservices with Go by Alexander Shuiskov(6521)
Practical Design Patterns for Java Developers by Miroslav Wengner(6419)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6397)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6382)
Angular Projects - Third Edition by Aristeidis Bampakos(5779)
The Art of Crafting User Stories by The Art of Crafting User Stories(5308)
NetSuite for Consultants - Second Edition by Peter Ries(5251)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5070)
Kotlin in Action by Dmitry Jemerov(5022)
